#!/bin/sh

function usage() {
    echo "$1 start | stop"
}

BIND_PORT[0]=8000
BIND_PORT[1]=8001
BIND_PORT[2]=8002


case "$1" in
  "start")
    for ((i=0; $i<3; i++))
    do
        echo "Starting server 127.0.0.1:${BIND_PORT[$i]}"
        gunicorn -b 127.0.0.1:${BIND_PORT[$i]} -w 2 --threads 4 --reload -D -p P-${BIND_PORT[$i]}.pid  -u root --access-logfile ./access.log --error-logfile ./error.log Taojin.wsgi
    done
    ;;
  "stop")
    ;;
  "*")
    echo "Unsupported command"
    usage $0
    ;;
esac
